package wechat.rcv.controller;

import com.google.common.base.Objects;
import com.shrcl.engineerprocess.domain.CorpWeChatUser;
import com.shrcl.engineerprocess.domain.CorpWeChatUserDAO;
import com.shrcl.engineerprocess.domain.Engineer;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import wechat.app.UserID;

@Controller
@SuppressWarnings("all")
public class NotificationList {
  private final static Logger logger = Logger.getLogger(NotificationList.class.getName());
  
  @Autowired
  private IObjectFactory entities;
  
  @Autowired
  private CorpWeChatUserDAO corpWeChatUserDAO;
  
  @RequestMapping("/notificationlist")
  public String process(@RequestParam(value = "code", defaultValue = "") final String code, @RequestParam(value = "state", defaultValue = "") final String state, final Model model) {
    String _xblockexpression = null;
    {
      NotificationList.logger.info("=========>NotificationList.processs<============");
      String _userId = UserID.getUserId(code);
      CorpWeChatUser _findActiveWeChatUser = this.corpWeChatUserDAO.findActiveWeChatUser(_userId);
      Engineer _engineer = null;
      if (_findActiveWeChatUser!=null) {
        _engineer=_findActiveWeChatUser.getEngineer();
      }
      final Engineer eng = _engineer;
      String hpage = "error";
      boolean _equals = Objects.equal(eng, null);
      if (_equals) {
        model.addAttribute("errormsg", "Invalid user");
      } else {
        final ArrayList<Object> arr = new ArrayList<Object>();
        model.addAttribute("result", arr);
        hpage = "notificationlist";
      }
      _xblockexpression = hpage;
    }
    return _xblockexpression;
  }
}
